import React, { useState } from 'react'
import SurveyForm from './components/SurveyFormPaginated'
import './App.css'

function App() {
  const [showSuccess, setShowSuccess] = useState(false)

  const handleSaveSuccess = () => {
    setShowSuccess(true)
    // 3秒后重置表单，允许继续填写
    setTimeout(() => {
      window.location.reload()
    }, 3000)
  }

  const handleCancel = () => {
    if (window.confirm('确定要清空表单吗？')) {
      window.location.reload()
    }
  }

  return (
    <div className="app">
      <header className="app-header">
        <h1>企业信息安全审计问卷</h1>
      </header>

      <main className="app-main">
        {showSuccess ? (
          <div className="success-message">
            <div className="success-icon">✓</div>
            <h2>提交成功！</h2>
            <p>感谢您填写问卷，页面将自动刷新...</p>
          </div>
        ) : (
          <SurveyForm
            survey={null}
            onSave={handleSaveSuccess}
            onCancel={handleCancel}
          />
        )}
      </main>
    </div>
  )
}

export default App
